﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CLeopardZip
{
    public partial class Form1 : Form
    {

        
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //this.label1.Text=  System.IO.Path.DirectorySeparatorChar.ToString();
           
            string fileToUnZip = @"E:\Projects\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\ICSharpCode.SharpZipLib.zip ";
            string zipedFolder = @"E:\Projects\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\temp ";

            this.backgroundWorker1.DoWork += new DoWorkEventHandler(DoWork);
            this.backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedWork);
            this.backgroundWorker1.RunWorkerAsync(this);
            ZipHelper.UnZip(fileToUnZip, zipedFolder);

        }

        private void CompletedWork(object sender, RunWorkerCompletedEventArgs e)
        {
            MessageBox.Show("解压成功！！", "解压提示");
        }

        private void DoWork(object sender, DoWorkEventArgs e)
        {
            string fileToUnZip = @"E:\Projects\WindowsFormsApplication2\WindowsFormsApplication2\test.zip ";
            string zipedFolder = @"E:\Projects\WindowsFormsApplication2\WindowsFormsApplication2\temp ";
            ZipHelper.UnZip(fileToUnZip, zipedFolder);
        }

        private void button2_Click(object sender, EventArgs e)
        {

            BackgroundWorker backgroundWorker = new BackgroundWorker();

            backgroundWorker.DoWork += new DoWorkEventHandler(DoWorkZIP);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedWorkZIP);
            backgroundWorker.RunWorkerAsync(this);

        }

        private void CompletedWorkZIP(object sender, RunWorkerCompletedEventArgs e)
        {
            MessageBox.Show("压缩成功！！", "解压提示");
        }

        private void DoWorkZIP(object sender, DoWorkEventArgs e)
        {
            string fileToZip = @"E:\Projects\WindowsFormsApplication2\WindowsFormsApplication2\temp";
            string zipedFile = @"E:\Projects\WindowsFormsApplication2\WindowsFormsApplication2\test1.zip";

            ZipHelper.Zip(fileToZip, zipedFile);
        }
    }
}
